fpath = "/etc/rc.d/rc.local"
if (FileTest.exist?(fpath))
	then
	system('cp monitor.rb /var/monitor.rb')
	fz = File.new fpath, "a"
	fz.puts "nohup ruby /var/monitor.rb &"
	fz.close
	puts "Monitor has been setup"
end
fpath = "/etc/rc.local"
if (FileTest.exist?(fpath))
	then
	system('cp monitor.rb /var/monitor.rb')
	fz = File.new fpath, "r+b"
	pos = fz.size-30
	fz.seek pos
	while fz.read(6)=~/exit 0/ do
		pos -=6 
		fz.seek pos
	end
	fz.seek pos
	fz.write "\nnohup ruby /var/monitor.rb &"
	fz.close
	puts "Monitor has been setup"
end

	
